﻿@model ContactManagement.Models.CategoriesListModel
@{
    ViewBag.Title = Html.Categories().GetCategoriesPageTitle();
}

<div class="span12">
    <h2>@Html.Categories().GetCategoriesElementTitle()</h2>
    <hr />
    <div class="well">
        @if (ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString) != EFCategoryTypes.UserRights.ToString())
        {
            @Html.RouteLink(GlobalResources.Navigation.CreateRESX, RouteNames.Categories.ToString(),
                            new { controller = EControllers.Administration.ToString(), category = ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString), action = EActionAdministration.CategoriesAdd.ToString() }, new { @class = "btn btn-small", data_icon = "icon-plus" })
        }
    </div>
</div>

<div class="span12">
    @Html.ShowCustomMessage()
</div>

<div class="span12">
    <table class="table table-striped @WebConstants.FilterTableRowsCssClass">
        <thead>
            <tr>
                <th>@GlobalResources.AccountViews.OptionsRESX
                </th>
                <th>ID
                </th>
                <th>@GlobalResources.AdminViews.NameRESX
                </th>
                <th>@GlobalResources.AdminViews.SortIDRESX
                </th>
                <th>@GlobalResources.AdminViews.ModuleNameRESX
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model.Categories)
            {
                <tr>
                    <td>@* Achtung für die UserRights Anzeige steht kein Bearbeiten oder Löschen Button für die Rechte zur Verfügung *@
                        @if (ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString) != EFCategoryTypes.UserRights.ToString())
                        {
                            // Achtung der Link muss algemeingültig aufgebaut werden, da diese Seite für alle Kategorien verwendet wird. muß im RouteData ausgelesen werden um welche Kategorie es sich handelt die Bearbeitet oder gelöscht werden soll. 
                            @Html.RouteLink(" ", RouteNames.Categories.ToString(),
                                        new { controller = EControllers.Administration.ToString(), category = ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString), action = EActionAdministration.CategoriesDelete.ToString(), id = item.ID }, new { @class = "btn btn-mini", data_icon = "icon-trash" })
                            @:&nbsp;
                            @Html.RouteLink(GlobalResources.Navigation.EditRESX, RouteNames.Categories.ToString(),
                                        new { controller = EControllers.Administration.ToString(), category = ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString), action = EActionAdministration.CategoriesEdit.ToString(), id = item.ID }, new { @class = "btn btn-mini" })
                            @Html.Categories().CreateUserGroupsEditLink(item.ID)
                        }
                        else
                        {
                            //Anzeige der Navigationspunkte die für die UserRights zur Verfügung stehen
                            @Html.RouteLink(GlobalResources.Navigation.AddUsersToUserRightsRESX, RouteNames.Categories.ToString(),
                                        new { controller = EControllers.Administration.ToString(), category = ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString), action = EActionAdministration.UserRightsShowUsers.ToString(), id = item.ID }, new { @class = "btn btn-mini" })
                        }
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ID)
                    </td>
                    <td>
                        @if (ViewContext.RouteData.GetRequiredString(WebConstants.CategoryString) != EFCategoryTypes.UserRights.ToString())
                        {
                            @Html.DisplayFor(modelItem => item.Name)
                        }
                        else
                        {
                            //Die userRightsnamen stehen in den Resourcen, diese hier laden und anzeigen.
                            @EFDataModel.Resources.UserRights.ResourceManager.GetString(item.Name)
                        }
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.SortId)
                    </td>
                    <td>
                        @item.GetModuleName()
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>


